<template>
    <div class="sysStMidTable">
        <el-table
            ref="receiveTable"
            size="mini"
            :data="resData"
            style="width: 100%"
            @selection-change="handleSelectionChange"
            highlight-current-row
            @cell-dblclick="changeJBtn"
        >
        <el-table-column type="selection" width="40"> </el-table-column>
        <el-table-column type="index" label="序号" width="50" :show-overflow-tooltip="true"> </el-table-column>
        <el-table-column prop="CONSOLENAME" label="接收台名称"  :show-overflow-tooltip="true"> </el-table-column>
        <el-table-column prop="CONSOLEIP" label="IP地址"  :show-overflow-tooltip="true"> </el-table-column>
        <el-table-column prop="CONSOLECALLBYWORKBIN" label="缓存箱叫箱地址"  :show-overflow-tooltip="true"> </el-table-column>
        <el-table-column prop="CONSOLESTATUS" label="工作状态"  :show-overflow-tooltip="true"> </el-table-column>
        <el-table-column prop="CONSOLEWORKBINMAXQUANTITY" label="缓存箱最大工作数量"  :show-overflow-tooltip="true"> </el-table-column>
        </el-table>
        <!-- 分页 -->
        <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="pageNumber"
            :page-sizes="[10, 20, 50, 100]"
            :page-size="pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="totalCount"
        >
        </el-pagination>
    </div>
</template>
<script>
import { sysReceiveTableData } from "@/utils/api.js"
export default {
    name:'SysStMidTable',
    data(){
        return{
            pageSize:20,
            pageNumber:1,
            totalCount:0,
            resData:[]
        }
    },
    methods:{
        // 勾选函数
        handleSelectionChange(val) {
            console.log(val)
            // 传给index 
            this.$bus.$emit('sysStMidSelect',val)
        },
        // 选择每页条数后请求接口更新表格
        handleSizeChange(val){
            this.pageSize = val
        },
        // 分页函数
        handleCurrentChange(val){
            this.pageNumber = val
        },
        // 统查表格数据
        searchTableData(){
            sysReceiveTableData({
                pageParameter:{
                    rows:this.pageSize,
                    page:this.pageNumber
                }
            }).then((res)=>{
                console.log('接受台数据查询',res)
                if(res.data.retCode == 200){
                    this.resData = res.data.responseBody.result
                    this.totalCount = res.data.responseBody.pageParameter.totalCount
                }else{
                    this.$Alert({
                        title: "失败",
                        message: res.data.message,
                        type: "error",
                    });
                }
            })
        },
        // 表格双击传参进行修改
        changeJBtn(val){
            this.$bus.$emit('sysStMidTableChange',val)
        }
    },
    mounted(){
        this.$options.methods.searchTableData.bind(this)()
        // 成功刷新Table
        this.$bus.$on('sysStReTables',(e)=>{
            this.$options.methods.searchTableData.bind(this)()
        })
    }
}
</script>
<style scoped>
.sysStMidTable {
    text-align: center;
}
</style>